<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>发送历史</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script type="text/javascript">
        var grid = null;
        $(function () {
            $("#ligergrid1").ligerGrid({
                url: '<%=path%>/syssms/sysSmsLog/initSendRecordList.do',
                method : 'get',
                columns: [
                    { display: '手机号', name: 'receivePhone', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '短信内容',minWidth: 650 ,name:'contents', align: 'center',isEllipsis: false,
                        /*render: function (rowdata, rowindex, value){
                            var h='<span class="gridTip" title="'+ value +'">'+ value +'</span>';
                            if(value == null){
                                return '<span></span>';
                            }else{
                                return h;
                            }
                        }*/
                    },
                    { display: '状态', name: 'smsStatusNm', minWidth: 80, align: 'center', enabledSort:true},
                    { display: '状态说明', name: 'sendResult', minWidth: 100, align: 'center', enabledSort:true},
                    { display: '发送时间',minWidth: 150 ,name:'sendDate', align: 'center',
                        render: function (rowdata, rowindex, value){
                            var dateStr = "";
                            if(null != value){
                                var date = new Date(value);
                                dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
                            }
                            return dateStr;
                        }
                    },
                    { display: '发送人', name: 'createName', minWidth: 100, align: 'center', enabledSort:true},
                    {
                        display: '操作',minWidth: 100,align: 'center',
                        render: function (rowdata, rowindex, value){
                            return '<a href="javascript:void(0);" onclick="againSendSMS(\''+rowdata.id+'\')">重新发送</a>';
                        }
                    }
                ],
                pageSize:10,
                root:'rows',
                record:'total',
                hideLoadButton : true,
                width: '100%',
                height:'100%',
                heightDiff:-2,
                //checkbox:true,
                rownumbers:true,
                fixedCellHeight: false,
                onAfterShowData: function () {
                    $(".gridTip").grid_ligerTip();
                    SetIframe_height ();
                }
            });
            grid = liger.get("ligergrid1");
            grid.setHeight(100);
            $("#searchBar").ligerForm();
            $("#dateform").ligerForm();
            $("#searchBtn").click(function(event) {
                var form = new liger.get("searchBar");
                var data = form.getData();
                console.log(data);
                for (name in data){
                    grid.setParm(name,data[name]);
                };
                if($("#sendDateBegin").val()>$("#sendDateEnd").val()){
                    $.ligerDialog.SQalert({content: "发送时间(起)不能大于发送时间(止)" , SQ_type: "warning" });
                    return;
                }
                grid.reload();
            });
            $("#clearBtn").click(function(event) {
                clearLigerForm("searchBar");
            });
        });

        function againSendSMS(_id){
            $.ligerDialog.confirm("是否确认重新发送?", function (flag) {
                if(flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType:'json',
                    data:'id='+_id,
                    url: '<%=path%>/syssms/sysSmsLog/againSendSMS.do',
                    beforeSend: function(){
                        wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                    },
                    success:function(msg){
                        wait_dialog.close();
                        if(msg.success == 1){
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                            grid.reload();
                        }else{
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                            grid.reload();
                        }
                    }
                });
            });
        }
        //导出
        function exportSmsExcel(){
            var url = '<%=path%>/syssms/sysSmsLog/exportSmsExcel.do';
            $("#searchBar").attr('action',url);
            $("#searchBar").submit();
            $("#searchBar").attr('action',"");
        }
    </script>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox col_33">
                    <div class="label">发送时间(起)</div>
                    <div class="field">
                        <input name="sendDateBegin" id="sendDateBegin" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">发送时间(止)</div>
                    <div class="field">
                        <input name="sendDateEnd" id="sendDateEnd" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">手机号</div>
                    <div class="field">
                        <input name="receivePhone" id="receivePhone" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">短信内容关键字</div>
                    <div class="field">
                        <input name="contents" id="contents" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">发送人</div>
                    <div class="field">
                        <input name="createName" id="createName" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_19"></i>清空</span>
                    <%--<span class="sq-button sq-button-hasicon" onclick="exportSmsExcel()"><i class="sqBtnIco_21"></i>导出</span>--%>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</body>
</html>
